The join operator concatenates a set of strings into a single string. The strings are appended to the resulting string in the order that they appear in the command.
String[] - Specifies one or more strings to be joined.
Delimiter - Specifies one or more characters placed between the concatenated strings. The default is no delimiter ("").
-Join <String[]> <String[]> -Join <Delimiter>
-join ("Windows", "PowerShell", "2.0") WindowsPowerShell2.0
The following statement joins three strings delimited by a space:
"Windows", "PowerShell", "2.0" -join " " Windows PowerShell 2.0
The following statements use a multiple-character delimiter to join three strings:
$a = "WIND", "S P", "ERSHELL" $a -join "OW" WINDOWS POWERSHELL
The following statement joins the lines in a here-string into a single string. Because a here-string is one string, the lines in the here-string must be split before they can be joined.
$a = @' a b c '@ (-split $a) -join " " a b c